# The five main Layout Containers that descend from the QLayout class namely, 
# QHBoxLayout, QVBoxLayout, QGridLayout, QStackedLayout and QFormLayout.
# QHBoxLayout and QVBoxLayout arrange widgets one after another horizontally and vertically.
# QGridLayout arranges widgets in tabular layout of any size.
# QStackedLayout arranges widgets on top of each other.
# QFormLayout is a specialized grid arrangement with two columns that provide special methods for arranging common forms 
# (e.g arranging labels in the first column and associated control in the second.
# Layouts can be further nested within other layouts to create more complex and flexible patterns for our interface.

# In this example, we create a simple form through HBoxLayout and VBoxLayout. 
# We can notice that its we need extra lines of code for resizing some widgets to make the interface look good.

import sys
from PySide import QtGui, QtCore

class Window(QtGui.QWidget):
    def __init__(self):
        super(Window, self).__init__()
        self.setGeometry(200, 200, 350, 90)
        self.setWindowTitle("HBox-VBox Layout: Dynamic Greeter")

        self.lblSalutation = QtGui.QLabel("Salutation ", self)
        self.cmbSalutation = QtGui.QComboBox(self)
        self.cmbSalutation.addItem(QtGui.QIcon("open.jpg"), "Hello, ")
        self.cmbSalutation.addItem("Hi, ")
        self.cmbSalutation.addItem(QtGui.QIcon("open.jpg"), "Salam, ")
        self.cmbSalutation.activated[str].connect(self.valueUpdate)
#         self.cmbSalutation.setMinimumSize(70, 50)
#         print(self.ledName.size())
        hbox1 = QtGui.QHBoxLayout()
        hbox1.addWidget(self.lblSalutation)
        hbox1.addWidget(self.cmbSalutation)


        self.lblName = QtGui.QLabel("Name ", self)
        # self.ledName = QtGui.QLineEdit(self)
        self.ledName = QtGui.QLineEdit(self)
        self.ledName.setPlaceholderText("This is place holder text")
        hbox2 = QtGui.QHBoxLayout()
        hbox2.addWidget(self.lblName)
        hbox2.addWidget(self.ledName)
        
        self.lblHello = QtGui.QLabel("", self)
        self.lblResult = QtGui.QLabel("", self)
        hbox3 = QtGui.QHBoxLayout()
        hbox3.addWidget(self.lblHello)
        hbox3.addWidget(self.lblResult)
        
        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(hbox1)
        vbox.addLayout(hbox2)
        vbox.addLayout(hbox3)
        
        self.setLayout(vbox)
        
    def valueUpdate(self, strRxd):
        self.lblHello.setText(strRxd)
        self.lblResult.setText(self.ledName.text())
        
if __name__ == "__main__":
    appObject = QtGui.QApplication(sys.argv)
    ex = Window()
    ex.show()
    sys.exit(appObject.exec_())
    